﻿Imports System.Data.Odbc
Public Class FrmLogin
    Private usu As String
    Private pass As String
    Dim connectionString As String
    Dim miconex As New OdbcConnection
    Dim midatareader As OdbcDataReader

    Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
        usu = TxtUser.Text
        pass = TxtPass.Text
        connectionString = "Driver={IBM INFORMIX ODBC DRIVER};" & _
        "database=siba_prueba;" & "host=192.168.1.250;" & _
        "srvr=ol_informix1170; serv=9088;" & _
        "pro=onsoctcp; uid=administrator; pwd=Uruguay.2013;" & _
        "cloc=en_US.CP1252; dloc=en_US.819"
        miconex = New OdbcConnection(connectionString)

        'abro la conexión
        Try
            miconex.Open()
            If miconex.State = ConnectionState.Open Then
                MessageBox.Show("Bienvenido, " & usu)
                'Dim command As OdbcCommand = New OdbcCommand("INSERT INTO usuarios VALUES(""pepito"", ""portero"")")
                'Dim command As OdbcCommand = New OdbcCommand("DELETE FROM usuarios WHERE nombre=""chleal""")
                Dim command As OdbcCommand = New OdbcCommand("SELECT * FROM usuarios")
                command.Connection = miconex
                midatareader = command.ExecuteReader
                'Dim coso = command.ExecuteNonQuery()
                While midatareader.Read
                    MsgBox(CStr(midatareader("nombre")) & CStr(midatareader("rol")))
                End While
                FrmPrincipal.Show()
            End If
        Catch ex As OdbcException
            MessageBox.Show("No anda pibe, proba mas tarde " & _
            ControlChars.CrLf & _
            ex.Message & ControlChars.CrLf & _
            ex.Source())
        End Try
        'FrmPrincipal.Show()
        'Me.Close()
        Me.Close()
    End Sub

    Private Sub FrmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
